<?php //callback for ajax/json

define( '_JEXEC', 1 );


define('JPATH_BASE', 'C:\xampp\htdocs\joomla_development\indie-bookstore\trunk' );

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;

/**
 * CREATE THE APPLICATION
 *
 * NOTE :
 */
$mainframe =& JFactory::getApplication('site');

/**
 * INITIALISE THE APPLICATION
 *
 * NOTE :
 */
// set the language
$mainframe->initialise();

require_once(JPATH_BASE .DS. 'components' .DS. 'com_bookstore' .DS. 'helpers' .DS. 'api.php');

//$isbn = $_GET['isbn'];
//var_dump($isbn);

//$api = new bookstore_api();
//var_dump($api);
//$local = $api->local_detail($isbn);
//var_dump($local);

class mapPage{

	function __construct(){

		$this->api =& new bookstore_api();
		
		
		//var_dump($this->detail);
		

	}//end constructor

	function getData(){
		
		$isbn = $_GET['isbn'];
		$this->local = $this->api->local_detail($isbn);
		if(strlen($isbn) == '10'){
			$this->detail = $this->api->external_detail($isbn);
		} //end if
		//var_dump($this->local);
		//var_dump($this->local->details);
		return;
		
	}//end getData
	
	function Populate(){
		
		$i = '0';
		
		foreach($this->local->details[$i] as $key=>$value){
			$this->local->$key = ucwords(strtolower($value));
		}//end foreach
		
		$this->local->dept_cat_desc = strtoupper($this->local->dept_cat_desc);
		
		//var_dump($this->local);
		
//foreach($this->local->details as $key){
//	$author[$i] = $this->local->details[$i]->author;
		
//		}//end foreach
		//echo $author;
	
	} //end Populate
	
	
	function showPage(){
		?>
<html><head>
<link rel="stylesheet" href="http://192.150.1.246/stable/tmp/css/style.css" type="text/css" />

<link href="../../tmp/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
		<div class="com" style="background-color:#000000">
<div class="box" style="background:url('http://192.150.1.246/stable/tmp/map_point_plot.php?sectionId=<?php echo $_GET['sectionId'];?>');width:350px;height:600px;float:left"></div>
<div class="box_right" style="width:240px;height:580px;float:left">
<center>
<div style="background-color:#BBFFDD;border-bottom-style:dotted;border-bottom-width:2px">
<br /><u><b><?php echo $this->local->dept_cat_desc;?></b></u><br><br></div>
<div style="background-color:#E0E0E0;border-bottom-style:dotted;border-bottom-width:2px"><u>Title</u>:<br><font color="#006600"><?php echo $this->local->title;?></font><br><br>
<u>Author</u>:<br><font color="#770000"><?php echo $this->local->author;?></font><br><br>
<u>Qty On-Hand</u>:<br><font color="#006600"><?php echo $this->local->avail_for_sale;?></font><br><br>
<u>Price</u>:<br><font color="#006600"><?php echo $this->local->retail_price_decimal;?></font><br><br>
</div><br>

<img src="<?PHP echo $this->detail->graphics;?>" /><br><br>

</center>
</div>
</div>
</body>
</html>
	<?php
	}//end showPage

} //end mapPage

$content = new mapPage();
//var_dump($isbn);
$local_data = $content->getData();
$content->Populate();
$content->showPage();

?>